import axios from '../utils/axios';

const CMD = {
    login:"/admin/login",
    getSwiper:"/home/swiper",
    getgroup:"/home/groups",
    getNews:"/home/news",
    getCityList:"/area/city?level=1",
    getCondition:"/houses/condition", //房源筛选条件
    gethouse:"/houses",  //获取房源 | 房屋具体信息
    getAreaMap:"/area/map", //获取地图房源
    searchCommunity:"/area/community",
    uploadImg:"/houses/image", 
    //uploadImg:"http://localhost:7001/api/addGroup", 
    uphouseInfo:"/user/houses",
}
const login = ({username,password}) =>{
    return axios.post(CMD.login,{
        username,
        password,
    })
}
const getSwiperImg = ()=>{
    return axios.get(CMD.getSwiper);
}
const getgroup = ()=>{
    return axios.get(CMD.getgroup);
}
const getnews = ()=>{
    return axios.get(CMD.getNews);
}
const getCityList = ()=>{
    return axios.get(CMD.getCityList)
}
const getCondition = (payload)=>{
    const {cityId} = payload;
    return axios.get(CMD.getCondition,{params:{id:cityId}})
}
const getHouse = (payload) =>{
    const {start,end,rentType,cityId='AREA|dbf46d32-7e76-1196'} = payload;
    return axios.get(CMD.gethouse,{
        params:{
            cityId,
            //area:'AREA|88cff55c-aaa4-e2e0',
            subway:'',
            rentType,
            price:'',
            more:'',
            roomType:'',
            oriented:'',
            characteristic:'',
            floor:'FLOOR|1',
            start,
            end,
        }
    })
}
const getHouseDetail = (payload) =>{  //房源详情
    const {id} = payload;
    return axios.get(CMD.gethouse+'/'+id)
}
const getAreaMap = (payload) =>{
    const {id} = payload;
    return axios.get(CMD.getAreaMap,{
        params:{id}
    })
}

const searchCommunity = (payload)=>{
    const {id,name} = payload;
    return axios.get(CMD.searchCommunity,{
        params:{
            name,
            id,
        }
    })
}

const uploadImg = (payload)=>{
   // const {file} = payload;
    return axios.post(CMD.uploadImg,payload)
}

const uphouseInfo = (payload) =>{
    // const {} = payload;
    return axios.post(CMD.uphouseInfo,payload)
}
export default  {
    login,
    getSwiperImg,
    getgroup,
    getnews,
    getCityList,
    getCondition,
    getHouse,
    getHouseDetail,
    getAreaMap,
    searchCommunity,
    uploadImg,
    uphouseInfo,
}